package com.lucenly.card.utils;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;

import java.io.File;

public class GlideUtils {
    private Context mContext;
    private static GlideUtils mInstance;
    private RequestOptions options;
    public GlideUtils(Context context) {
        this.mContext = context;
        options = new RequestOptions();
    }
    public static GlideUtils getInstance(Context context) {
        if (mInstance == null) {
            synchronized (GlideUtils.class) {
                if (mInstance == null) {
                    mInstance = new GlideUtils(context);
                }
            }
        }
        return mInstance;
    }
    public void load(Context context,String path, ImageView imageView,int placeImg){
        options.placeholder(placeImg);
        options.error(placeImg);
        options.centerCrop();
        options.diskCacheStrategy(DiskCacheStrategy.ALL);
        Glide.with(context).load(path).apply(options).into(imageView);
    }
}
